package com.grupoconstruobras.sigo.exhumaciones.ui.datamodel;

import javax.persistence.EntityManager;
import javax.persistence.Tuple;

public class CriteriaDataModelFactory implements IDataModelFactory<Tuple> {

	private IQueryBuilder builder;
	
	public CriteriaDataModelFactory(EntityManager entityManager, IQueryBuilder builder) {
		this.builder = builder;
		builder.setEntityManager(entityManager);
	}
	
	@Override
	public ExtendedDataModel<Tuple> newInstance(IDataModelCallback<Tuple> callback, Object ... parameters) {
		builder.setParameters(parameters);
		return new CriteriaDataModel(callback, builder);
	}
	
	@Override
	public ExtendedDataModel<Tuple> newInstance(Object ... parameters) {
		builder.setParameters(parameters);
		return new CriteriaDataModel(builder);
	}
	
}
